

var geocoder;
var map;
var marker;
var latlng;

function initialize() {
  geocoder = new google.maps.Geocoder();
  latlng = new google.maps.LatLng(-34.397, 150.644);
  var mapOptions = {
    zoom: 8,
    center: latlng
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  marker = new google.maps.Marker({
          map: map,
          position: latlng,
          draggable: true
      });
}

function codeAddress() {
  var address = document.getElementById('address').value;
  geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      map.setCenter(results[0].geometry.location);
      marker.setPosition(results[0].geometry.location);
      latlng = results[0].geometry.location;      
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }
  });
  console.log(marker);
}
console.log(geocoder);
google.maps.event.addDomListener(window, 'load', initialize);

        



(function($) {
  var GMap = (function(){
     var _self = this;
     //set
     _self.var = {
         latlng : null,
         map : null,
         marker : null,
         geocoder : null        
     }
     
     var setPosition = function(position) {
         _self.var.marker.setPosition(position);
         _self.vars.map.panTo(position);
         
     };z/ZX?ZX;zcp
  });
}(jQuery));